// main.cpp
// Copyright (C) 2008 Sam Bateman
// samuel.bateman@gmail.com
//
// This file is part of DVD On Fire.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

//! @file main.cpp
//! @author Sam Bateman
//! @brief Source file for the main function.

#include <cstdio>
#include <ctime>
#include "data.h"
#include "encoder.h"
#include "step.h"
using namespace dvdonfire::daemon;
using namespace std;

// main(argc, argv) {{{
int main(int argc, char **argv)
{
    // test
    timespec sleep_time;
    sleep_time.tv_sec = 0;
    sleep_time.tv_nsec = 100000000;
    Data *data = new Data;
    Step *step = new Encoder();
    step->setData(data);
    step->start();
    while (!step->isDone()){
        printf("\rProgress: %.6f", step->getProgress());
        fflush(stdout);
        nanosleep(&sleep_time, NULL);
    }
    if (step->getError() != ""){
        printf("Error: %s\n", step->getError().c_str());
    }
    else {
        printf("\rProgress: 1.000000\n");
    }
    step->stop();
    delete step;
    delete data;
}
// }}}
